
<section id="content">

    <div class="page page-fullwidth-layout">

        <div class="pageheader">

            <div class="page-bar">

                <ul class="page-breadcrumb">
                    <li>
                        <a href="{:url('/admin')}"><i class="fa fa-home"></i> 起始页</a>
                    </li>
                    <li>
                        <a href="{:url($data.module_url)}">{$data.module_name}列表</a>
                    </li>
                </ul>

            </div>

        </div>

        <!-- page content -->
        <div class="pagecontent">

            <!-- row -->
            <div class="row">
                <!-- col -->
                <div class="col-md-12">
                    <!-- tile -->
                    <section class="tile">
                        <form action="{:url($data.module_url)}" style="padding-top:10px" class="navbar-form form-inline" method="post">
                            <div class="form-group">
                                <label class="control-label" for="input-mobile">手机号码</label>
                                <div class="input-group">
                                    <input type="text" name="mobile" value="" placeholder="手机号码" id="input-mobile" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label" for="input-c_nickname">微信昵称</label>
                                <div class="input-group">
                                    <input type="text" name="c_nickname" value="" placeholder="微信昵称" id="input-c_nickname" class="form-control">
                                </div>
                            </div>


                            <div class="form-group">
                                <button type="submit" class="btn btn-primary pull-right"><i class="fa fa-search"></i> 查詢</button>

                            </div>
                            <button  type="button" onclick="saveImport(0);" class="btn btn-primary"><i class="fa"></i>导入</button>
                            <button  type="button" onclick="distribut(0);" class="btn btn-primary"><i class="fa"></i> 分配</button>
                        </form>
                        <div class="tile-body">
                           <div class="alert alert-info" style="display:none;">显示一些提示信息</div>

                            <div class="table-responsive">
                                <table class="table table-striped table-hover table-custom" id="products-list">
                                    <thead>
                                        <tr>
                                            <th><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);"></th>
                                            <th>用户名</th>
                                            <th>微信昵称</th>
                                            <th>微信头像</th>
                                            <th>手机号</th>
                                            <th>性别</th>
                                            <th>会员等级</th>
                                            <th>客户状态</th>
                                            <th>添加时间</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>

                                        {foreach $list as $item}
                                        <tr id="tr_{$item['uncustomers_id']}">
                                            <td class="id"><input type="checkbox" name="selected[]" value="{$item['uncustomers_id']}"></td>
                                            <td class="name">{$item['name']}</td>
                                            <td class="c_nickname">{$item['c_nickname']}</td>
                                            <td class="header_pic"><img src="{$item['header_pic']}" width="40" style="border-radius: 50%;"/> </td>
                                            <td class="mobile">{$item['mobile']}</td>
                                            <td>
                                                {if condition="$item['sex'] eq 1"}男{elseif condition="$item['sex'] eq 2"}女{else/}保密{/if}
                                            </td>
                                            <td>
                                                {if condition="$item['customer_levlel'] eq 1"}
                                                    铜牌
                                                {elseif condition="$item['customer_levlel'] eq 2"}
                                                    银牌
                                                {elseif condition="$item['customer_levlel'] eq 3"}
                                                    金牌
                                                {elseif condition="$item['customer_levlel'] eq 4"}
                                                    钻石
                                                {/if}
                                            </td>
                                            <td>
                                                {if condition="$item['customer_type'] eq 1"}
                                                     新增客户
                                                {elseif condition="$item['customer_type'] eq 2"}
                                                     潜在客户
                                                {elseif condition="$item['customer_type'] eq 3"}
                                                     意向客户
                                                {elseif condition="$item['customer_type'] eq 4"}
                                                     准客户
                                                {elseif condition="$item['customer_type'] eq 5"}
                                                     合作客户
                                                {elseif condition="$item['customer_type'] eq 6"}
                                                     已认证
                                                {else/}
                                                     已放弃
                                                {/if}
                                            </td>
                                            <td>{$item['addtime']|date='Y-m-d H:i',###}</td>
                                            <td>
                                                <a class="btn btn-info" href="{:url($data.module_url.'read',['uncustomers_id'=>$item['uncustomers_id']])}">
                                                    <i class="glyphicon glyphicon-edit icon-white"></i>
                                                    编辑
                                                </a>
                                                <a class="btn btn-danger" href="javascript:;"  onclick="if(confirm('确定要删除该客户吗')){ deleteData({$item['uncustomers_id']})}">
                                                    <i class="glyphicon glyphicon-trash icon-white"></i>
                                                    删除
                                                </a>
                                            </td>

                                        </tr>
                                        {/foreach}
                                    </tbody>
                                </table>
                            </div>
                            <div class="text-center">{$list->render()}</div>
                        </div>
                        <!-- /tile body -->

                    </section>
                    <!-- /tile -->

                </div>
                <!-- /col -->
            </div>
            <!-- /row -->

        </div>
        <!-- /page content -->

        <script type="text/javascript">

            function deleteData(uncustomers_id){
                $.ajax({
                    type:"get",
                    data: {'uncustomers_id':uncustomers_id},
                    url:"{:url($data.module_url.'delete')}",
                    success:function(data){
                        if(data.error == 0){
                            $('#tr_'+data.uncustomers_id).remove();
                        }
                        $('.alert').html(data.msg).show();
                        setTimeout(function() {
                            $('.alert').hide();
                        }, 3000);
                    },
                    error:function(data){

                    }
                });
            }

            //分配客户
            function distribut(id){
                var obj = $("input[name*='selected']");
                var url = "{:url($data.module_url.'distribut')}";
                if(obj.is(":checked")){
                    var check_val = [];
                    for(var k in obj){
                        if(obj[k].checked)
                            check_val.push(obj[k].value);
                    }
                    url += "?uncustomers_id_array="+check_val;
                    layer.open({
                        type: 2,
                        title: '分配客户',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['580px', '480px'],
                        content: url
                    });
                }else{
                    layer.msg('请选择客户');
                }
            }
            //导入
            function saveImport(){
                $('#myModal').modal('show');
            }
            //提交导入
            function checkform(){
                document.getElementById("myform").submit();
            }

        </script>

    </div>

</section>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">导入</h4>
            </div>
            <div class="modal-body">
                <form method="post" action="{:url($data.module_url).'saveImport'}" id="myform" class="form-signin" enctype="multipart/form-data" >
                    <input name="excel" type="file" >
                </form>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="checkform()">导入</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>